<style>
.layui-form-label { width: 30%!important;}
.layui-form-label div{ font-size: 12px;font-weight: normal;color: #AC6363;}
.layui-input-block {margin-left: 30%;}
.layui-form-item{border-bottom: 1px solid #f5f5f5;}
.layui-card-body, .layui-card-header, .layui-form-label, .layui-form-mid, .layui-form-select, .layui-input-block, .layui-input-inline, .layui-textarea { width: 300px; }
.regular .layui-form-select{float: left; width: 150px;}
</style>

<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
	
		<!-- END RIBBON -->
		<div class="content">
			<div class="panel panel-default panel-intro">
				<div class="panel-heading">
					<div class="panel-lead">
						<em>CMS - ILDM创建</em>
						...
					</div>
				</div>
				<div class="panel-body">
					<div id="myTabContent" class="tab-content">
						<div class="tab-pane fade active in" id="one">
							<div class="widget-body no-padding">
								<div class="bootstrap-table">
									
									<div class="fixed-table-toolbar">
										<div class="bs-bars pull-left">
											<div id="toolbar" class="toolbar">
												<a href="javascript:window.location.reload();" class="btn btn-primary btn-refresh" title="刷新">
													<i class="fa fa-refresh"></i>
												</a>
											</div>
										</div>
										<div class="columns columns-right btn-group pull-right">
											
										</div>
									</div>
									<div class="fixed-table-container" style="padding-bottom: 0px;">


<div class="fixed-table-body">
<div id="main" role="main">
	<div class="tab-content tab-addtabs">
		<div id="content">
			<div class="row">
				<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
						<div class="content">
						<form class="layui-form" >
								
								<div class="layui-form-item">
									<label class="layui-form-label" style="padding-bottom:0">
										控制器名称
										<div>(只能由英文字母、数字和下划线组成，并且仅能字母开头，不以下划线结尾)</div>
									</label>
									<div class="layui-input-block">
										<input type="text" class="layui-input" id="name">
									</div>
								</div>
								<div class="layui-form-item">
									<label class="layui-form-label" style="padding-bottom:0"> 
										控制器别名
										<div>例如：你也可以理解为分类名称</div>
									</label>
									<div class="layui-input-block">
										<input type="text" class="layui-input" id="title">
									</div>
								</div>
								<div class="layui-form-item">
									<label class="layui-form-label" style="padding-bottom:0">
										父级控制器
										<div>例如：你也可以理解为父级分类</div>
									</label>
									<div class="layui-input-block">
										<select class="layui-input" id="pid">
											<option value="0">默认顶级</option>
											{$html}
										</select>
									</div>
								</div>
								<div class="layui-form-item">
									<label class="layui-form-label">
										选择模型
									</label>
									<div class="layui-input-block">
										<select class="layui-input" id="im_id" lay-filter="im_id">
											<option value="0">请选择对应模型</option>
											{volist name="model" id="vo" key="k" }
												<option value="{$vo.im_id}">{$vo.im_name} ({$vo.im_table})</option>
											{/volist}
										</select>
									</div>
								</div>
								<div class="layui-form-item">
									<label class="layui-form-label">
										控制器描述
									</label>
									<div class="layui-input-block">
										<textarea style="min-height: 60px;width: 600px;margin-bottom: 10px;" class="layui-textarea" id="des"></textarea>
									</div>
								</div>

								<div class="layui-form-item" id="A1">
									<label class="layui-form-label">
										是否兼容WAP视图切换
									</label>
									<div class="layui-input-block">
										<input type="checkbox" name="wap" lay-skin="switch">
									</div>
								</div>

						</form>
					</div>
				</div>
			</div>
		</div>
	</div>
</div>




										</div>
									</div>
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>




												
<script>

layui.use(['form'], function(){
	var form = layui.form;
	// 查询模型所属
	form.on('select(im_id)', function(data){
		var t = data.value;
		$.ajax({
			type: 'post',
			data: {'id':t},
			async: false,
			url: "{:url('vif_model')}",
			success: function(data) {
				var array = eval('('+data+')');
				res = array;
				$('#name').attr('disabled', false);
				$('#name').css('background', '#fff');
				$('#A1').show();
				if (array['code'] == '01') {
					$.thinkmimi({Content : array['msg'], Type:2, Align:'right', OutTime:2000});
				} else if (array['code'] == '02') {
					$.thinkmimi({Content : array['msg'], Type:1, Align:'right', OutTime:2000});
				} else {
					$.thinkmimi({Content : array['msg'], Type:1, Align:'right', OutTime:2000});
					$('#name').val(array['data']);
					$('#name').attr('disabled', true);
					$('#name').css('background', '#f5f5f5');
					$('#A1').hide();
				}
			}
		});
	});
});

function doSubimt() {
	var res;
	var title = $('#title').val();
	var name  = $('#name').val();
	var des   = $('#des').val();
	var im_id = $('#im_id').val();
	var pid   = $('#pid').val();
	var wap   = 0;
	if ($("input[name='wap']").is(':checked')) {
		wap = 1;
	}

	var data    = {'pid':pid, 'name':name, 'title':title, 'des':des, 'im_id':im_id, 'wap':wap};

	if (name == '') {
		$.thinkmimi({Content : '请输入控制器名称！', Type:2, Align:'right', OutTime:2000});return false;
	}
	if (title == '') {
		$.thinkmimi({Content : '请输入控制器别名', Type:2, Align:'right', OutTime:2000});return false;
	}
	if (im_id == '' || im_id==0) {
		$.thinkmimi({Content : '请选择数据模型！', Type:2, Align:'right', OutTime:2000});return false;
	}

	$.ajax({
		type: 'post',
		data: data,
		async: false,
		url: "{:url('add')}",
		success: function(data) {
			var array = eval('('+data+')');
			res = array;
			if (array['code'] == '01') {
				$.thinkmimi({Content : array['msg'], Type:2, Align:'right', OutTime:2000});
				res = false;
			}
		}
	});
	return res;
}
</script>